// pages/orderDetails/orderDetails.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    // 收货人信息模拟数据
    info: [],
    // 商品信息模拟数据
    array: [],
    // 订单信息模拟数据
    orderInfo: []
  },
  all() {
    var that = this
    wx.request({
      url: app.globalData.baseUrl + '/order/findOrderByOrderStatus',
      data: {
        xcxOpenId: 'dasdasdasddasdas3',
        orderStatus: ''
      },
      success(res) {
        var arr = res.data.data.rows
        var list1 = []
        var status = ''
        arr.forEach((item, index) => {
          list1.push(item.orderProductList)
          list1[index].pay = item.payAmout
          list1[index].currencyAmount = item.currencyAmount
          status = item.orderStatus
        })
        // 获取订单状态
        switch (status) {
          case '1':
            status = '待付款'
            break;
          case '2':
            status = '待发货'
            break;
          case '3':
            status = '待收货'
            break;
          case '4':
            status = '退换中'
            break;
          case '5':
            status = '已完成'
            break;
          case '6':
            status = '已取消'
            break;
        }
        list1.forEach(item => {
          item.status = status
          item.imgSrc = app.globalData.baseUrl + '/getFile?id=' + item.productSpecsDTO.specsAttId
        })
        that.setData({
          array: list1
        })
      }
    })
  },
  // 待付款
  toBePaid() {
    var that = this
    wx.request({
      url: app.globalData.baseUrl + '/order/findOrderByOrderStatus',
      data: {
        xcxOpenId: app.globalData.xcxOpenId,
        orderStatus: 1
      },
      success(res) {
        var data = res.data.data.rows
        var orderCode = data[0].orderCode
        wx.request({
          url: app.globalData.baseUrl + '/order/findOrderDetailByOrderCode',
          data: {
            xcxOpenId: app.globalData.xcxOpenId,
            orderStatus: 5
          },
          success(res) {
            var orderInfo = []
          }
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    this.all()
  }
})